<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
	<% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
		+ request.getServerPort() + path + "/" ; %>

		<!DOCTYPE html>
		<html>

		<head>
			<base href="<%=basePath%>">

			<title>合同签署</title>

			<meta http-equiv="pragma" content="no-cache">
			<meta http-equiv="cache-control" content="no-cache">
			<meta http-equiv="expires" content="0">
			<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
			<meta http-equiv="description" content="This is my page">
			<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

		</head>

		<body>
			<%@ include file="/WEB-INF/jsp/common/header.jsp" %>
				<%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

					<script type="text/javascript">
						$(function () {
							$('#startTime').datebox('setValue', getBeforeCurrentDate30Days());
							$('#endTime').datebox('setValue', getNowFormatDate());
							bindgrid();
						});
					</script>
					<script>
						function del(node) {
							$.ajax({
								type: "delete",
								url: 'sys/mm/delete?mmId=mmId',
								//                dataType: "xml",				
								success: function (data) {
									$.messager.alert('消息', data);
									$('#add').window('close');
									bindgrid();
								},
								error: function (XMLHttpRequest, textStatus, errorThrown) {
									$.messager.alert('消息', errorThrown);
								}
							});
						}

						function save() {
							if (!$('#fm').form('validate')) {
								return;
							}
							var model = {
								mmId: $('#mmId').textbox('getValue'),
								nedMmCode: $('#nedMmCode').textbox('getValue'),
								nedMmDetail: $('#nedMmDetail').textbox('getValue'),
								nedMmUnit: $('#nedMmUnit').textbox('getValue'),
								nedMmCategory: $('#nedMmCategory').textbox('getValue'),
								nedMmMain: $('#nedMmMain').textbox('getValue'),
								nedMmSecond: $('#nedMmSecond').textbox('getValue'),
								nedMmNature: $('#nedMmNature').textbox('getValue'),
								nedMmTypeCode: $('#nedMmTypeCode').textbox('getValue'),
								nedMmTypeName: $('#nedMmTypeName').textbox('getValue'),
								nedPlanNum: $('#nedPlanNum').textbox('getValue'),
								nedStockNum: $('#nedStockNum').textbox('getValue'),
								nedNeedDate: $('#nedNeedDate').textbox('getValue'),
								nedDevice: $('#nedDevice').textbox('getValue'),
								nedQm: $('#nedQm').textbox('getValue'),
								nedUse: $('#nedUse').textbox('getValue'),
								nedUseName: $('#nedUseName').textbox('getValue'),
								nedUseTel: $('#nedUseTel').textbox('getValue'),
								nedOutType: $('#nedOutType').textbox('getValue'),
								nedRemark: $('#nedRemark').textbox('getValue'),
								createTime: $('#createTime').textbox('getValue'),
								createName: $('#createName').textbox('getValue'),
								createId: $('#createId').textbox('getValue'),
								updateId: $('#updateId').textbox('getValue'),
								updateName: $('#updateName').textbox('getValue'),
								updateTime: $('#updateTime').textbox('getValue'),
								delFlag: $('#delFlag').textbox('getValue'),
								status: $('#status').textbox('getValue'),
								remark: $('#remark').textbox('getValue')
							};
							$.ajax({
								type: "post",
								dataType: "json",
								url: 'sys/mm/save',
								data: JSON.stringify(model),
								contentType: "application/json",
								success: function (data) {
									if (data.code != 60200) {
										$.messager.alert('消息', data.msg);
									} else {
										$.messager.alert('消息', data.msg);
										let dg = $('#dg');
										dg.datagrid('enableFilter');
										dg.datagrid('load');
										$('#add').window('close');
									}
								},
								error: function (XMLHttpRequest, textStatus, errorThrown) {
									$.messager.alert('消息', errorThrown);
								}
							})

						}

						function editrow() {
							//编辑用户
							var row = $('#dg').datagrid('getSelected');
							if (row) {
								$('#add').window('open');
								$('#fm').form('load', row);

							} else {
								$.messager.alert('消息', '请选中一个用户');
							}
						}
					</script>
					<script>
						function selectList() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							var dg = $('#dg');
							dg.datagrid('enableFilter');
							dg.datagrid('load', {
								startTime: startTime ? startTime : '',
								endTime: endTime ? endTime : ''
							});
						}
						function bindgrid() {
							var startTime = $('#startTime').datebox('getValue')
							var endTime = $('#endTime').datebox('getValue')
							$('#dg').datagrid(
								{
									title: '物料列表',
									url: "sys/mm/selectList",
									iconCls: 'icon-application',
									width: getWidth(0.98),
									height: 415,
									queryParams: {
										startTime: startTime,
										endTime: endTime
									},
									filterDelay: 0,
									nowrap: true,
									rownumbers: true,
									animate: false,
									collapsible: false,
									clientPaging: false,
									remoteFilter: true,
									singleSelect: true,
									pagination: true,
									remoteSort: true,
									columns: [[
										{
											field: 'mmId',
											title: '物资id',
											sortable: true,
											hidden: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										},
										{
											field: 'nedMmCode',
											title: '物资编码',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										},
										{
											field: 'nedMmDetail',
											title: '物资描述',
											sortable: true,
											width: 210,
											formatter: function (val, rec) {
												if (val) {
													return '<span title="' + val + '">'
														+ val + '</span>';
												} else {
													return val;
												}
											}
										}, {
											field: 'nedMmUnit',
											title: '计量单位',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										},
										{
											field: 'mmUnitDetail',
											title: '计量单位描述',
											sortable: true,
											formatter: function (val, rec) {
												return unescape(val ? val : '')
											}
										}, {
											field: 'nedMmCategory',
											title: '物资品名',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										},
										{
											field: 'suttle',
											title: '净重',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedMmMain',
											title: '主特征',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedMmSecond',
											title: '副特征',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedMmNature',
											title: '计量性质',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedMmTypeCode',
											title: '物资类别编码',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedMmTypeName',
											title: '物资类别名称',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedPlanNum',
											title: '需求计划量',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedStockNum',
											title: '库存量',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedNeedDate',
											title: '需用日期',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedDevice',
											title: '设备位号',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedQm',
											title: '质量技术要求',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedUse',
											title: '用途',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedUseName',
											title: '使用人姓名',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedUseTel',
											title: '使用人联系方式',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedOutType',
											title: '出库类型',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'nedRemark',
											title: '行备注',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'createTime',
											title: 'create_time',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'createName',
											title: 'create_name',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'createId',
											title: 'create_id',
											sortable: true,
											hidden: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'updateId',
											title: 'update_id',
											sortable: true,
											hidden: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'updateName',
											title: 'update_name',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'updateTime',
											title: 'update_time',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'delFlag',
											title: 'del_flag',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'status',
											title: 'status',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}, {
											field: 'remark',
											title: 'remark',
											sortable: true,
											formatter: function (val, rec) {
												return val ? unescape(val) : '';
											}
										}]],
									toolbar: [
										{
											text: '增加',
											iconCls: 'icon-add',
											handler: function () {
												$('#fm').form('clear');
												$('#add').window('open');
											}
										},
										'-',
										{
											text: '编辑',
											iconCls: 'icon-edit',
											handler: function () {
												var row = $('#dg').datagrid(
													'getSelected');
												if (row) {
													$('#add').dialog('open').dialog(
														'center').dialog(
															'setTitle', '');
													$('#fm').form('load', row);

												}
											}
										},
										'-',
										{
											text: '删除',
											iconCls: 'icon-cancel',
											handler: function () {
												var row = $('#dg').datagrid(
													'getSelected');
												if (row) {
													$.messager.confirm('提示',
														'确定要删除吗?', function (r) {
															if (r) {
																del(row);
															}
														});
												}
											}
										}],
									onLoadSuccess: function () {
									},
									onDblClickRow: function () {
										editrow();
									}
								});
							$('#dg').datagrid('enableFilter');
						}
					</script>
					<style scoped="scoped">
						.textbox {
							height: 20px;
							margin: 0;
							padding: 0 2px;
							box-sizing: content-box;
						}

						/*.table tr {
        height: 15px;
    }*/
					</style>
					<div style="margin: 5px 0px">
						<%-- 搜索框 --%>
							<label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox" name="startTime"
								id="startTime"
								data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
								value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
								class="easyui-datebox" name="endTime" id="endTime"
								data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
								style="width: 150px" /> <a id="search" style="margin-left: 30px"
								href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
								onclick="selectList()">查询</a>
					</div>
					<table id="dg"></table>


					<div id="add" class="easyui-window" closed="true" modal="true" title="用户信息"
						style="width: 500px; height: 450px; padding: 10px 20px">
						<form id="fm" class="ssec-form">
							<table class="table">
								<tr>
									<td>
										<div class="ssec-label">物资id：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="mmId" name="mmId" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">物资编码：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmCode" name="nedMmCode" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">物资描述：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmDetail" name="nedMmDetail" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">计量单位：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmUnit" name="nedMmUnit" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">物资品名：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmCategory" name="nedMmCategory" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">主特征：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmMain" name="nedMmMain" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">副特征：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmSecond" name="nedMmSecond" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">计量性质：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmNature" name="nedMmNature" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">物资类别编码：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmTypeCode" name="nedMmTypeCode" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">物资类别名称：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedMmTypeName" name="nedMmTypeName" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">需求计划量：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedPlanNum" name="nedPlanNum" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">库存量：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedStockNum" name="nedStockNum" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">需用日期：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedNeedDate" name="nedNeedDate" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">设备位号：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedDevice" name="nedDevice" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">质量技术要求：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedQm" name="nedQm" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">用途：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedUse" name="nedUse" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">使用人姓名：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedUseName" name="nedUseName" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">使用人联系方式：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedUseTel" name="nedUseTel" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">出库类型：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedOutType" name="nedOutType" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">行备注：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="nedRemark" name="nedRemark" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">create_time：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="createTime" name="createTime" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">create_name：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="createName" name="createName" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">create_id：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="createId" name="createId" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">update_id：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="updateId" name="updateId" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">update_name：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="updateName" name="updateName" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">update_time：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="updateTime" name="updateTime" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">del_flag：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="delFlag" name="delFlag" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">status：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="status" name="status" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
								<tr>
									<td>
										<div class="ssec-label">remark：</div>
									</td>
									<td>
										<div class="ssec-text normal">
											<input id="remark" name="remark" class="easyui-textbox"
												data-options="required:true" />
										</div>
									</td>
								</tr>
							</table>
							<div style="padding: 5px; text-align: right;">
								<a class="easyui-linkbutton" onclick="save();" iconcls="icon-save">保存</a>
							</div>
						</form>
					</div>
		</body>

		</html>